package com.sqsf.mapper;

import com.sqsf.javabean.RList;
import com.sqsf.javabean.Role;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

public interface RoleMapper {
    // 查询所有角色
    @Select("select * from role")
    List<Role> selectAll();

    // 添加角色
    @Insert("insert into role (roleName, roleDesc) values (#{roleName}, #{roleDesc})")
    int insert(Role role);

    //删除角色
    @Delete("delete from role where id = #{id}")
    int deleteById(int id);

    @Delete("delete from role_permission where roleId = #{rid}")
    int deleteByRid(int rid);

    //批量删除
    int deleteByList(ArrayList<Integer> ids);

    int deleteR_PByList(ArrayList<Integer> ids);

    Role selectR_PById(int id);

    @Update("update role set roleName = #{roleName}, roleDesc = #{roleDesc} where id = #{id}")
    int updateById(Role role);

    @Delete("delete from role_permission where roleId = #{id}")
    int deleteR_PById(int id);

    int insertR_P(@Param("rid") Integer rid, @Param("ids") List<Integer> ids);
}
